package com.start.security.data.permission;


import com.start.common.details.BaseUserDetails;
import com.start.common.vo.SysMenuDataRulesVo;
import com.start.security.StartUserPermissionTools;
import com.start.security.annotations.DataPermission;
import org.apache.commons.lang3.StringUtils;

import jakarta.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 系统默认数据权限注入器
 */
public class DataStartPermissionComponentType implements StartPermissionInjector {

    private StartUserPermissionTools userPermissionTools;

    public DataStartPermissionComponentType(StartUserPermissionTools userPermissionTools) {
        this.userPermissionTools = userPermissionTools;
    }

    @Override
    public List<SysMenuDataRulesVo> getRules(HttpServletRequest request, BaseUserDetails currentUser, DataPermission dataPermission) {
        if (StringUtils.isEmpty(dataPermission.value())) return null;
        return userPermissionTools.getUserMenuDataRulesByComponent(currentUser,dataPermission.value());
    }


}
